package com.xhwl.data.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xhwl.common.pojo.ResultJson;
import com.xhwl.common.pojo.cent.sdata.PositionExcelRecord;
import com.xhwl.common.pojo.cent.sdata.space.OrganizationImport;
import com.xhwl.data.dao.OrganizationImportDao;
import com.xhwl.data.service.IOrganizationImportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: luyi
 * @Description:
 * @Date: Create in 11:10 2021/10/26
 */
@Service
public class OrganizationImportServiceImpl extends ServiceImpl<OrganizationImportDao, OrganizationImport> implements IOrganizationImportService {


    @Override
    public ResultJson getOrganizationHistoryImport(Integer enterpriseId, String fileName, Page page) {

        return ResultJson.success(this.page(enterpriseId,fileName,page));
    }

    @Override
    public Page page(Integer enterpriseId, String fileName, Page page) {
        QueryWrapper<OrganizationImport> positionExcelRecordQueryWrapper = new QueryWrapper<>();
        positionExcelRecordQueryWrapper.orderByDesc("created_at");
        positionExcelRecordQueryWrapper.eq("enterprise_id", enterpriseId);
        if (null != fileName) {
            positionExcelRecordQueryWrapper.like("file_name", fileName);
        }
        Page page1 = this.page(page, positionExcelRecordQueryWrapper);
        return page1;
    }
}
